package com.dai.rpc.bean;

import com.dai.rpc.proxy.MyHttpClientProxy;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class MyHttpClientFactoryBean<T> implements FactoryBean<T>{

    private Class<T> interfaceClass;


    // 构造方法
    public Class<?> getInterfaceClass() {
        return interfaceClass;
    }

    public void setInterfaceClass(Class<T> interfaceClass) {
        this.interfaceClass = interfaceClass;
    }

    @Override
    public boolean isSingleton() {
        // true 是单例，false是非单例
        return true;
    }



    @Override
    public T getObject() throws Exception {
        // 从容器中获取接口bean,构建代理对象返回
        return new MyHttpClientProxy().getProxy(interfaceClass);
    }

    @Override
    public Class<?> getObjectType() {
        return interfaceClass;
    }



}
